﻿using System;
using System.Collections.Generic;
using System.Linq;
using core6_website.Models.EnumTypes;

namespace core6_website.Models
{
    public class MockRepo : IStudentRepo
    {
        private readonly List<Student> _studentList;

        public MockRepo() {
            _studentList = new List<Student>()
            {
                new Student() { Id = 1, Name = "张三", Major = MajorEnum.ComputerScience,
                Email = "zhangesan@52abp.com"},
                 new Student() { Id = 3, Name = "李四", Major = MajorEnum.ElectronicCommerce,
                Email = "zhangesan@54abp.com"},
                  new Student() { Id = 4, Name = "赵六", Major = MajorEnum.Mathematics,
                Email = "zhangesan@54abp.com"},
            };
        }

        public Student Add(Student student)
        {
            student.Id = _studentList.Max(s => s.Id) + 1;
            _studentList.Add(student);

            return student;
        }

        public IEnumerable<Student> GetAllStudents()
        {
            return _studentList;
        }

        public Student GetStudent(int id)
        {
            return _studentList.FirstOrDefault(a => a.Id == id); 
        }

        public void Save(Student student)
        {
            throw new NotImplementedException();
        }
    }
}
